//
//  XS_GoalCertItemCell.swift
//  XueDao
//
//  Created by Mac on 2020/12/15.
//

import UIKit

class XS_GoalCertItemCell: UICollectionViewCell {

    @IBOutlet weak var backView: UIView!
    @IBOutlet weak var statusView: UIView!
    @IBOutlet weak var statusLabel: UILabel!
    @IBOutlet weak var imgView: UIImageView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var contentLabel: UILabel!
    
    var _model : XS_CourseItemModel!
    public var model : XS_CourseItemModel!{
        set{
            _model = newValue
            //设置数据
            statusLabel.text = newValue.percentage == "100" ? "已学完" : ("学习中"+newValue.percentage + "%")
            statusView.backgroundColor = newValue.percentage == "100" ? UIColor.qmui_color(withHexString: "#C4C6CD") : UIColor.qmui_color(withHexString: "#D4F2EB")
            statusLabel.textColor = newValue.percentage == "100" ? UIColor.qmui_color(withHexString: "#ffffff") : UIColor.qmui_color(withHexString: "#2ABD9C")
            titleLabel.text = newValue.curriculumName
            contentLabel.text = "共"+newValue.curriculumNum+"节"
            imgView.sd_setImage(with: URL.init(string: newValue.curriculumImgUrl), completed: nil)
        }
        get{
            return _model
        }
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        backView.layer.shadowRadius = 12
        backView.layer.shadowOffset = CGSize(width: 0, height: 2)
        backView.layer.shadowColor = UIColor(red: 0.18, green: 0.20, blue: 0.20, alpha: 0.06).cgColor
        backView.layer.shadowOpacity = 1
        backView.layer.cornerRadius = 4
        
        statusView.layer.masksToBounds = true
        statusView.layer.cornerRadius = .scale * 2
        imgView.layer.masksToBounds = true
        imgView.layer.cornerRadius = .scale * 4
    }

}
